//
//  JKMVWebViewController.m
//  JiuKuMusic
//
//  Created by jiukuyinyue on 16/5/16.
//  Copyright (c) 2016年 JiuKuForApp. All rights reserved.
//

#import "JKMVWebViewController.h"
//#import "MyTabBarView.h"

@interface JKMVWebViewController ()<UIWebViewDelegate>

@property (nonatomic, strong)UIWebView * mvWebView;

@end

@implementation JKMVWebViewController


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
//    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];

}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:YES];
//    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
//    self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:1];
//    self.navigationItem.hidesBackButton =YES;
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"titleBack" higlightedImage:nil target:self action:@selector(leftBtnAction)];
    self.navigationController.navigationBar.hidden = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    //导航栏颜色
    self.navigationController.navigationBar.barTintColor = JK_HUISE_LINE_COLOR;
    //导航栏字体颜色
    self.navigationItem.title = self.webTitle;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    UIView * leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    UIImageView * LeftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, 11, 19)];
    LeftImageView.userInteractionEnabled = YES;
    NSString * backStr = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"new返回%@", [TheHomeManager shareTheHomeManager].iPhone23] ofType:@"png"];
    LeftImageView.image = [UIImage imageWithContentsOfFile:backStr];
    [leftView addSubview:LeftImageView];
    UITapGestureRecognizer * backTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftBtnAction)];
    [leftView addGestureRecognizer:backTap];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftView];

    [self setupUI];
    
}
- (void)leftBtnAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)setupUI
{
    
//    self.mvWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, self.view.height/4-22, self.view.width, self.view.width*0.7)];
    self.mvWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    _mvWebView.delegate = self;
    _mvWebView.backgroundColor = [UIColor clearColor];
    NSURLRequest * request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.webStr]];
    [self.view addSubview:self.mvWebView];
    [self.mvWebView loadRequest:request];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//网页开始加载
- (void )webViewDidStartLoad:(UIWebView  *)webView
{
    MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode=MBProgressHUDAnimationFade;//枚举类型不同的效果

}

//网页完成加载
- (void )webViewDidFinishLoad:(UIWebView  *)webView
{
    [self hiddenMBAction];
}

//网页加载失败
- (void)webView:(UIWebView *)webView  didFailLoadWithError:(NSError *)error
{
    [self hiddenMBAction];
}


- (void)hiddenMBAction
{
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
